home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / FILEIO.MOD < prev    next >
Text File  |  1989-01-18  |  1KB  |  45 lines

  1.                                          (* Chapter 8 - Program 3 *)
  2. MODULE FileIO;
  3.  
  4. FROM InOut IMPORT WriteString, WriteInt, WriteLn, Write, Read,
  5.                   OpenInput, OpenOutput, CloseInput, CloseOutput,
  6.                   Done;
  7.  
  8. IMPORT Terminal;                 (* This is used for monitor output *)
  9.                                  (* and InOut is used for the file  *)
  10.                                  (* input and output.               *)
  11.  
  12. VAR Character : CHAR;
  13.  
  14. BEGIN
  15.    REPEAT                                    (* open the input file *)
  16.       Terminal.WriteString("Enter Input filename  - ");
  17.       OpenInput("MOD");
  18.    UNTIL Done;                      (* Quit when open is successful *)
  19.  
  20.    REPEAT                                   (* open the output file *)
  21.       Terminal.WriteString("Enter Output filename - ");
  22.       OpenOutput("DOG");
  23.    UNTIL Done;                  (* quit when the open is successful *)
  24.  
  25.    REPEAT                (* character read/write loop - quit at EOF *)
  26.       Read(Character);
  27.       IF Done THEN                           (* Done = FALSE at EOF *)
  28.          Write(Character);
  29.       END;
  30.    UNTIL NOT Done;
  31.    CloseInput;
  32.    CloseOutput;
  33.  
  34. END FileIO.
  35.  
  36.  
  37.  
  38.  
  39. (* Result of execution
  40.  
  41. (The selected file is copied to another file character by character.)
  42.  
  43. *)
  44.  
  45.